import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home', // 重定向:重新指向其它path,会改变网址
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('../views/home'),
    children: [
      {
        path: '/home',
        redirect: '/home/default',
      },
      {
        path: '/home/default',
        name: 'default',
        title: '首页',
        component: () => import('../views/home/default'),
      },
      {
        path: '/home/list',
        name: 'list',
        title: '列表',
        component: () => import('../views/home/list'),
      },
    ],
  },
  {
    path: '/detail/:id',
    name: 'detail',
    component: () => import('../views/detail'),
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('../views/search'),
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

export default router
